import {
    request
} from "../../request/index.js";
var redis = require("../../utils/redis.js").default;
Page({
    data: {
        collect: [],
    },
    
    onLoad: function (options) {
        this.queryCollectGoodsByUserId();
    },
    async queryCollectGoodsByUserId() {
        // let token = wx.getStorageSync('token');
        const token = redis.get('token');
        if (!token) {
          wx.navigateTo({
            url: '/page/login/index'
          });
          return;
        }
        let userId = redis.get('userId');
        const res = await request({
          url: "/collects/queryCollectGoodsByUserId",
          data: {
            userId
          }
        });
        console.log("获取用户商品收藏结果：");
        console.log(res.data);
        if (200 === res.data.code) {
            this.setData({
                collect: res.data.data
            })
        }
      }
})